;;; init.el --- mainfun
;;; Commentary:
;;; Code:
;;;========================================================================
(setq configuration-layer--elpa-archives
    '(("melpa-cn" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")
      ("org-cn"   . "https://mirrors.tuna.tsinghua.edu.cn/elpa/org/")
      ("gnu-cn"   . "https://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")))
;;------------------------------------------------------------------------

;;关闭工具栏
(tool-bar-mode 0)

;;关闭起动界面
(setq inhibit-startup-screen t)

;;行号
(global-display-line-numbers-mode t)

;;按一次 C-u
(repeat-mode 1)

;;高亮行
;;(global-hl-line-mode 1)
;;(set-face-background 'hl-line "@1111")

;;自动加载
(global-auto-revert-mode 1)

;;关闭自动生产
(setq auto-save-default nil)

;;简化yes
(fset 'yes-or-no-p 'y-or-n-p)

;;括号自动补全
(electric-pair-mode t)

;;当是终端模式时,打开鼠标支持
(unless (display-graphic-p)
  (xterm-mouse-mode t))

;;防止备份文件 file.txt~
(setq make-backup-files nil)

;;eldoc打开简化
(global-set-key (kbd "C-c h") 'eldoc-doc-buffer)

;;关闭警告声与屏幕闪烁
(setq visible-bell nil
      ring-bell-function 'ignore)

;;指令提示
(use-package which-key
  :ensure t
  :init
  (add-hook 'after-init-hook #'which-key-mode))

;;更好的指令系统
(use-package consult
  :ensure t
  :bind
  (("C-s" . consult-line)))
;;垂直命令补全
(use-package vertico
  :ensure t
  :hook (after-init . vertico-mode))
;;无序排序
(use-package orderless
  :ensure t
  :init
  (setq completion-styles '(orderless)))
;;为指令提供注解
(use-package marginalia
  :ensure t
  :init (marginalia-mode)
  :bind (:map minibuffer-local-map
			  ("M-A" . marginalia-cycle)))
;;命令历史
(use-package amx
  :ensure t
  :init (amx-mode))

(defun open-config()
  "Open the emacs configuration file."
  (interactive)
  (find-file "~/.emacs.d/init.el"))

;;更好的单行移动
(use-package mwim
  :ensure t
  :bind
  ("C-a" . mwim-beginning-of-code-or-line)
  ("C-e" . mwim-end-of-code-or-line))

;;多窗口切换
(use-package ace-window
  :ensure t
  :bind (("C-x o" . 'ace-window)))

(use-package rainbow-delimiters
  :ensure t
  :hook (prog-mode . rainbow-delimiters-mode))

(use-package company
  :ensure t
  :hook
  ((eglot-managed-mode . company-mode)))

;;; init.el ends here
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(package-selected-packages nil))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )
